﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using StockUtil;

namespace StockLib
{
    /// <summary>
    /// 板块组数据更改处理器
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    public delegate void StockBlockGroupDataEventHandler(object sender, EventArgs e);

    /// <summary>
    /// 板块组下的版块数据更改处理器
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    public delegate void StockBlockGroupStockDataEventHandler(object sender, EventArgs e);


    /// <summary>
    /// 板块组
    /// </summary>
    public class StockBlockGroup : Dictionary<string, StockBlock>
    {
        /// <summary>
        /// 板块组数据更改事件
        /// </summary>
        public event StockBlockGroupDataEventHandler DataChanged;

        /// <summary>
        /// 板块组下的版块数据更改事件
        /// </summary>
        public event StockBlockGroupStockDataEventHandler StockDataChanged;

        /// <summary>
        /// 加载"分类"板块组数据
        /// </summary>
        public virtual void Load()
        {
        }

        /// <summary>
        /// 保存"分类"板块组数据
        /// </summary>
        public virtual void Save()
        {
        }

        /// <summary>
        /// 手动触发板块组数据更改事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void RaiseDataChanged(object sender, EventArgs e)
        {
            if (DataChanged != null)
            {
                DataChanged(sender, e);
            }
        }

        /// <summary>
        /// 手动触发板块组下的版块数据更改事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void RaiseStockDataChanged(object sender, EventArgs e)
        {
            if (StockDataChanged != null)
            {
                StockDataChanged(sender, e);
            }
        }
    }
}
